﻿using System;

namespace Cat.Core.XLog.Log4Net
{
    partial class Log4NetLogger
    {
        protected override void Debug(Exception exception, Lazy<string> message)
        {
            if (!_log.IsDebugEnabled) return;
            var msg = message?.Value;
            if (exception == null) _log.Debug(msg);
            else _log.Debug(msg, exception);
        }

        protected override void Info(Exception exception, Lazy<string> message)
        {
            if (!_log.IsInfoEnabled) return;
            var msg = message?.Value;
            if (exception == null) _log.Info(msg);
            else _log.Info(msg, exception);
        }

        protected override void Warn(Exception exception, Lazy<string> message)
        {
            if (!_log.IsWarnEnabled) return;
            var msg = message?.Value;
            if (exception == null) _log.Warn(msg);
            else _log.Warn(msg, exception);
        }

        protected override void Error(Exception exception, Lazy<string> message)
        {
            if (!_log.IsErrorEnabled) return;
            var msg = message?.Value;
            if (exception == null) _log.Error(msg);
            else _log.Error(msg, exception);
        }

        protected override void Fatal(Exception exception, Lazy<string> message)
        {
            if (!_log.IsFatalEnabled) return;
            var msg = message?.Value;
            if (exception == null) _log.Fatal(msg);
            else _log.Fatal(msg, exception);
        }

    }
}

